﻿<%@ Page Title="" Language="C#" MasterPageFile="~/Views/Shared/Site.Master" Inherits="System.Web.Mvc.ViewPage<BookTheBook.Web.Helpers.PaginatedListCollection<BookTheBook.Data.Model.Book>>" %>
<%@ Import Namespace="BookTheBook.Data.Model" %>
<%@ Import Namespace="BookTheBook.Web.Helpers" %>

<asp:Content ID="Content1" ContentPlaceHolderID="TitleContent" runat="server">
	Search amazon.com
</asp:Content>

<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server">
    <h2>Enter your search</h2>
    
    <%
        var query = string.Empty;
        if (Model != null)
        {
            query = Model.Query;
        }
    %>
    
    <% using (Html.BeginForm("Submit", "Search"))
       {
    %>
    <div id="search">
        <input type="text" name="query" value="<%=query%>" />
        <input type="submit" value="Search" />
        <br />
    </div>
    <%} %>
    
    <div id="searchResults">
    <%
        if (null != Model)
        {
            if (Model.Count > 0)
            {
                foreach (Book book in Model)
                {%>
                <div class="book <%=StyleCalculator.CalculateCSSClassName(book) %>">

                <img class="image" alt="<%=book.Title %>" src="<%=book.ImageUrl%>" height="160px;" width="118px;"/>
                
                <% Html.RenderPartial("CommonBookInfo", book); %>
                
                </div> 
     <%         }
            }
            else
            {
                %>
                    <span>No results</span>
     <%
            }
        }
        %>
     </div>

      <% Html.RenderPartial("Pagination", Model); %>
    
</asp:Content>
